package com.gongyibao.gbase.support;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author: 张启峰
 * @Date: 2023/4/18 11:37
 * @Description: gyb-
 */
public class Test {
    public static void main(String[] args) {
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(3000);
        poolConfig.setMaxIdle(3000);
        poolConfig.setMaxWaitMillis(3000);

        Set<String> set = new HashSet();
        set.add("192.168.6.53:26379");
        set.add("192.168.6.54:26379");
        set.add("192.168.6.56:26379");

        JedisSentinelPool pool = new JedisSentinelPool("DefaultService",
                set, poolConfig, 0, 0, null, 0, null,
                0, 0, "123456", null);
        Jedis jedis = pool.getResource();

        jedis.set("aaa", "ddd");
        System.out.println("aaa = " + jedis.get("aaa"));

        pool.close();
        jedis.close();
    }
}
